<?php


	$xtpl = new XTemplate( "themes/".$global_config['themes']."/modules/main/posthome.tpl");
	$data2 = array();
	$menu = array();
	$sqlmenu = $db->fetch_array("SELECT `id`,`title`,`alias`,`func` FROM tb_menu
								 WHERE `status` = 1 and `id` in (1,3)");//Số ID menu cấp cha muốn hiển thị
	foreach($sqlmenu as $menu)	{
		$sub = NULL;	
		$datamenu = $db->fetch_array("SELECT id FROM tb_menu
								 WHERE `status` = 1 and `group` =" .$menu['id']. "");	//5 6
		foreach($datamenu as $menusub ){
			$sub .= $menusub['id'].",";	
		}
		$sub .='0';
		$data2[$sub]	= array(
					'titleg' => $menu['alias']
					);					 
		$datamenu = $db->fetch_array("SELECT `alias`,`title`,`img`,`hometext` FROM `post_rows`
								 WHERE `status` = 1 and `listcat` in (" .$sub. ")");
		foreach($datamenu as $datam){							 
			$data2[$sub][] = array(				
					'title'=>$datam['title'],
					'link'=>$menu['alias']."/".$datam['alias'],
					'img'=>$nv_Request->chuyenLinkURL($datam['img'],$global_config['img']),
					'hometext'=>$datam['hometext']
					);
		}	
	}
	
	foreach($data2 as $dt){	
			$xtpl->assign('POSTC',$dt);	
			$i=0;
		foreach($dt as $dt1){		
			if($i>0){
				if($i<3){			
					$xtpl->assign('POST',$dt1);
					$xtpl->parse( 'main.posthome.2post' );
				}
				else{
					$xtpl->assign('POST',$dt1);
					$xtpl->parse( 'main.posthome.post' );
				}
			}
			$i++;
		}
		$xtpl->parse( 'main.posthome' );
	}
	
	$xtpl->parse( 'main' );
	$data .= $xtpl->text('main');



?>

